Imports CapaDeDatos
Public Class nTblEnteC
    Private TblEnteC As dTblEnteC = New dTblEnteC()
    Private Localidad As nLocalidad = New nLocalidad()
    Public Function Insertar(ByVal RazonSocial As String, ByVal Direccion As String, ByVal TelCel As String, ByVal Mail As String, ByVal CodigoLocalidad As String) As Boolean
        If (RazonSocial <> "" And Direccion <> "" And CodigoLocalidad <> "" And Not TblEnteC.Existe(RazonSocial, "")) Then
            Return TblEnteC.Insertar(RazonSocial, Direccion, TelCel, Mail, CodigoLocalidad)
        Else
            Return False
        End If
    End Function
    Public Function Modificar(ByVal CodigoEnte As String, ByVal RazonSocial As String, ByVal Direccion As String, ByVal TelCel As String, ByVal Mail As String, ByVal Estado As String, ByVal CodigoLocalidad As String) As Boolean
        If (RazonSocial <> "" And Direccion <> "" And CodigoLocalidad <> "" And Not TblEnteC.Existe(RazonSocial, CodigoEnte)) Then
            Return TblEnteC.Modificar(CodigoEnte, RazonSocial, Direccion, TelCel, Mail, Estado, CodigoLocalidad)
        Else
            Return False
        End If
    End Function
    Public Function Buscar(ByVal CodigoEnte As String, ByVal RazonSocial As String, ByVal Direccion As String, ByVal TelCel As String, ByVal Mail As String, ByVal Estado As String, ByVal CodigoLocalidad As String) As DataSet
        If Estado = "Ninguno" Then
            Estado = ""
        End If
        If CodigoLocalidad = "-1" Then
            CodigoLocalidad = ""
        End If

        Dim dtsPrincipal As DataSet
        dtsPrincipal = TblEnteC.BuscarFiltrado(CodigoEnte, RazonSocial, Direccion, TelCel, Mail, Estado, CodigoLocalidad)
        dtsPrincipal.Tables(0).Columns.Add("Descripcionlocalidad")
        Dim i As Integer
        For i = 0 To dtsPrincipal.Tables(0).Rows.Count - 1
            Try
                dtsPrincipal.Tables(0).Rows(i)("Descripcionlocalidad") = Localidad.Buscar(dtsPrincipal.Tables(0).Rows(i)("CodigoLocalidad").ToString()).Tables(0).Rows(0)("Nombre").ToString()
            Catch ex As Exception
                dtsPrincipal.Tables(0).Rows(i)("Descripcionlocalidad") = "Error, lo q vos quieras"
            End Try
        Next
        Return dtsPrincipal

    End Function
    Public Function Eliminar(ByVal CodigoEnte As String) As Boolean
        If (CodigoEnte <> "") Then
            Return TblEnteC.Eliminar(CodigoEnte)
        Else
            Return False
        End If
    End Function

End Class
